/*
 * jxUtils Project (2014)
 * 
 * by Denilson Edinaldo Pinto
 * 
 * LGPL
 * Copyright (C) 2014
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
package org.jxUtils.file.type;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.jxUtils.collection.CollectionUtil;
import org.jxUtils.file.type.document.ms.PPS;
import org.jxUtils.file.type.document.ms.PPSX;
import org.jxUtils.file.type.document.ms.PPT;
import org.jxUtils.file.type.document.ms.PPTX;
import org.jxUtils.file.type.document.open.ODP;
import org.jxUtils.file.type.document.open.OTP;

/**
 * @author Denilson Edinaldo Pinto
 * @porject jxUtils
 * @package org.jxUtils.file.type
 * @date 23/11/2014 - 09:25:03
 */
public final class PresentationType implements CollectionFileType {
	
	private static Set<FileTypeFace> TYPES = new HashSet<FileTypeFace>();
	
	static {
		
		TYPES.add(new ODP());
		TYPES.add(new OTP());
		TYPES.add(new PPS());
		TYPES.add(new PPSX());
		TYPES.add(new PPT());
		TYPES.add(new PPTX());
	}
	
	@Override
	public boolean contains(final String extension) {
	
		return containsInAny(extension);
	}
	
	@Override
	public String extensionsToString() {
	
		final StringBuilder extensions = new StringBuilder();
		
		//
		for(final FileTypeFace type : getTypes()) {
			
			extensions.append(type.toString() + " ");
		}
		
		return extensions.toString().trim();
	}
	
	@Override
	public String[] getExtensions() {
	
		final List<String> extensions = getAllExtensions();
		
		final String[] strExtensions = new String[extensions.size()];
		
		return extensions.toArray(strExtensions);
	}
	
	@Override
	public String[] getExtensionsWithoutPoint() {
	
		final List<String> extensionsAux = getAllExtensions();
		
		//
		for(final String extension : getAllExtensions()) {
			
			extensionsAux.add(extension.substring(1));
		}
		
		final String[] strExtensions = new String[extensionsAux.size()];
		
		return extensionsAux.toArray(strExtensions);
	}
	
	/**
	 * @param extension
	 */
	public static boolean containsInAny(final String extension) {
	
		return FileType.containsInAny(extension, getTypes());
	}
	
	/**
	 * @return all extensions
	 */
	public static List<String> getAllExtensions() {
	
		return FileType.getAllExtensions(getTypes());
	}
	
	/**
	 * @return types
	 */
	public static List<FileTypeFace> getTypes() {
	
		return CollectionUtil.clone(TYPES);
	}
}
